import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const myStore = new Vuex.Store({
  //这里是存储共享数据的地方
  state: {
    /*图书ID*/
    bookId:'',
    /*登录之前要去的*/
    routerBeforeLoginTo:'/',
    isLogin:false,
    /*个人中心info界面跳转订单时选中哪个状态*/
    orderState:'7',
    /*后端URL*/
    url:'http://localhost:8201',
    /*个人中心*/
    userId:localStorage.getItem('uid')||0,
    user : {
      nick:'',phone:'',email:'',avatar:''
    }
  },
  getters: {
  },
  //一般的，在这里通过方法来修改 state 里面的属性值
  mutations: {
    setUserId(state,userId){
      state.userId = userId
    },
    setUser(state,user){
      state.user = user
    },
    setOrderState(state,orderState){
      state.orderState = orderState
    },
    setIsLogin(state,loginState){
      state.isLogin = loginState
    }
  },
  actions: {
  },
  modules: {
  }
})
export default myStore
